package com.hhhn.wk.widget.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * * * * * * * * * * * *
 * @author：WenKe ｡◕‿◕｡ *
 * Data：2017     ｡◕‿◕｡ *
 * QQ：370820580  ｡◕‿◕｡ *
 * Function：     ｡◕‿◕｡ *
 * 将MyAdaper2设置成泛型
 * * * * * * * * * * * */

public abstract class MyAdaper<T> extends BaseAdapter {
    private List<T> mList;//list数据
    private int mLayoutRes;//布局id
    public MyAdaper(List<T> mList, int mLayoutRes) {
        this.mLayoutRes = mLayoutRes;
        this.mList = mList;
    }
    @Override
    public int getCount() {
        return mList!=null?mList.size():0;
    }
    @Override
    public T getItem(int position) {
        return mList.get(position);
    }
    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder= ViewHolder.bind(parent.getContext(), convertView, parent,mLayoutRes,position);
        bindView(holder,getItem(position),position);
        return holder.getItemView();
    }
    public abstract void bindView(ViewHolder holder, T obj, int position);
}
